package com.dishes.douguo.Controller;


import com.dishes.douguo.Service.userService;
import com.dishes.douguo.domain.User;
import com.dishes.douguo.util.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(tags = "用户管理")
@RestController
@RequestMapping("/dishes/douguo/user")
public class userController {

    @Autowired
    userService service;

    @ApiOperation("用户登录")
    @CrossOrigin
    @PostMapping ("/Login")
    public AjaxResult Login(@Validated @RequestBody User user){

        User result = service.Login(user);
        if(result!=null){
            return  AjaxResult.success(result);
        }else {

            return  AjaxResult.error("密码错误");
        }


    }
    @ApiOperation("添加用户")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody User user){

        service.add(user);

        return AjaxResult.success("添加成功");
    }



}
